package com.zy.openchat.core.manager;

public class DownloadVideoManager {
    private BlockTaskQueue mTaskQueue = BlockTaskQueue.getInstance();
    private ShowTaskExecutor mExecutor;
    private volatile static DownloadVideoManager downloadManager;
    public static DownloadVideoManager getIntance() {
        if (downloadManager == null) {
            synchronized (DownloadVideoManager.class) {
                if (downloadManager == null) {
                    downloadManager = new DownloadVideoManager();
                }
            }
        }
        return downloadManager;
    }
    private DownloadVideoManager(){
        initExecutor();
    }

    private void initExecutor() {
        mExecutor = new ShowTaskExecutor(mTaskQueue);
        mExecutor.start();
    }

    public void enqueue(DownloadTask task){
        if (!mExecutor.isRunning()) {
            mExecutor.startRunning();
        }
        mTaskQueue.add(task);
    }

}
